//数据库运行命令nodemon
const mongoose = require('mongoose');

// 连接 MongoDB
mongoose.connect('mongodb+srv://2065554075:11111@cluster0.dsmvgmd.mongodb.net/xiang')
    .then(() => console.log('MongoDB 连接成功'))
    .catch(err => console.error('MongoDB 连接失败', err));
const loginSchema = new mongoose.Schema({
    username: String,
    password: String,
    img: String,
    name: String
})
    
let videos = new mongoose.Schema({
    title:String,
    likes:Number,
    favorites:Number,
    url:String
})
let data = new mongoose.Schema({
    name: String,
    bfs: String,
    dzs: String,
    time: String,
})
let errors = new mongoose.Schema({
    errorTime: { type: Date, default: Date.now },
    errorType: String,
    fieldType: String,
    errorTitle: String,
    errorDescription: String,
    source: String
})
let errorsModel = mongoose.model('errors', errors, 'errors');
const loginModel = mongoose.model('login', loginSchema, 'login');
let videosModel = mongoose.model('videos',videos,'videos')
let dataModel = mongoose.model('data',data,'data')
module.exports ={
    loginModel,
    videosModel,
    dataModel,
    errorsModel
}
